<?php

namespace app\api\validate;

use think\Validate;

/**
 *  退款订单验证器
 */
class Refund extends Validate
{

    // 定义验证规则
    protected $rule = [
        'version|版本号' => 'require|eq:1.0',
        'merchant_id|商户号' => 'require',
        'merchant_order_id|退款商户订单号' => 'require|alphaNum|length:5,32',
        'old_merchant_order_id|原商户订单号' => 'require|alphaNum|length:5,32',
        'app_id|应用ID' => 'require',
        'cash|金额' => 'require|float|egt:0.01|length:1,8',
        'trade_type|交易类型' => 'require',
        'body|退款说明' => 'require|length:1,50',
        'name|姓名' => 'require|length:1,50',
        'id_card|身份证号' => 'require|length:1,50',
        'mobile|手机号' => 'require|length:1,50',
        'notify_open|通知开关' => 'require|in:0,1',
        'notify_url|通知地址' => 'require|length:1,300',
        'ip|IP地址' => 'require|ip',
        'user_id|用户ID' => 'require|number|length:1,20',
        'channel_id|渠道ID' =>  'require|length:1,50',
        'format|格式' => 'require',
        'sign_type|签名类型' => 'require',
        'extra|商户自定义备注' => 'length:0,300',
        'start_time|创建时间' => 'require|number|length:10,11',
        'random_string|随机字符串' => 'require',
        'sign|签名' => 'require',
        'order_id|平台订单号' => '',
    ];
    // 定义验证提示
    protected $message = [];

    // 定义场景
    //    protected $scene = [
    //        'cash' => ['merchant_id' => 'require', 'start_time' => 'require', 'random_string' => 'require', 'sign' => 'require'],
    //    ];
    // 验证场景定义
    public function sceneCash()
    {
        return $this->only(['merchant_id', 'start_time', 'random_string', 'sign'])
            ->append('merchant_id', 'require');
    }
}
